from dev_control.enums.camera_enum import CameraTypeEnum
class AimAtRequest:
    def __init__(self, camera_type, locked=True, payload_index="89-0-0", x=0.0, y=0.0):
        self.camera_type = camera_type  # 相机类型
        self._locked = locked  # 机头和云台的相对关系是否锁定
        self._payload_index = payload_index  # 相机枚举
        self._x = x  # 目标坐标 x
        self._y = y  # 目标坐标 y

    # Getter and Setter for camera_type
    @property
    def camera_type(self):
        return self._camera_type

    @camera_type.setter
    def camera_type(self, value):
        if not isinstance(value, CameraTypeEnum):
            raise ValueError("camera_type must be an instance of cameraTypeEnum")
        self._camera_type = value.value

    # Getter and Setter for locked
    @property
    def locked(self):
        return self._locked

    @locked.setter
    def locked(self, value):
        if not isinstance(value, bool):
            raise ValueError("Locked must be a boolean value")
        self._locked = value

    # Getter and Setter for payload_index
    @property
    def payload_index(self):
        return self._payload_index

    @payload_index.setter
    def payload_index(self, value):
        if not isinstance(value, str):
            raise ValueError("Payload index must be a string")
        self._payload_index = value

    # Getter and Setter for x (target coordinate x)
    @property
    def x(self):
        return self._x

    @x.setter
    def x(self, value):
        if not (0 <= value <= 1):
            raise ValueError("x must be between 0 and 1")
        self._x = value

    # Getter and Setter for y (target coordinate y)
    @property
    def y(self):
        return self._y

    @y.setter
    def y(self, value):
        if not (0 <= value <= 1):
            raise ValueError("y must be between 0 and 1")
        self._y = value

    def __repr__(self):
        return (f"AimRequest(camera_type={self.camera_type}, locked={self.locked}, "
                f"payload_index={self.payload_index}, x={self.x}, y={self.y})")

    def to_dict(self):
        """
        将对象转换为字典形式，方便序列化或传输。
        """
        return {
            "camera_type": self.camera_type.value,  # 使用 Enum 的值
            "locked": self.locked,
            "payload_index": self.payload_index,
            "x": self.x,
            "y": self.y
        }